Visualizing raw trial looking time

d_no_target <- d %>% 
  filter(trial_stimulus_type != "target")

Looking time distribution

RAW

data_with_demog %>% 
  ggplot(aes(x = trial_looking_time)) + 
  geom_histogram(bins = 90) + 
  xlim(0, 9000)
## Warning: Removed 72 rows containing non-finite values (stat_bin).
## Warning: Removed 2 rows containing missing values (geom_bar).

data_with_demog %>% 
  ggplot(aes(x = trial_looking_time)) + 
  geom_histogram(bins = 90) + 
  xlim(0, 9000) + 
  facet_wrap(~subject)
## Warning: Removed 72 rows containing non-finite values (stat_bin).
## Warning: Removed 134 rows containing missing values (geom_bar).

AFTER EXCLUSION

d %>% 
  ggplot(aes(x = trial_looking_time)) + 
  geom_histogram(bins = 90) + 
  xlim(0, 6000)
## Warning: Removed 2 rows containing missing values (geom_bar).

d %>% 
  ggplot(aes(x = trial_looking_time)) + 
  geom_histogram(bins = 90) + 
  xlim(0, 6000) + 
  facet_wrap(~subject)
## Warning: Removed 84 rows containing missing values (geom_bar).

Exclude the target trial

d_no_target %>% 
  ggplot(aes(x = trial_looking_time)) + 
  geom_histogram(bins = 90) + 
  xlim(0, 6000)
## Warning: Removed 2 rows containing missing values (geom_bar).

d_no_target %>% 
  ggplot(aes(x = trial_looking_time)) + 
  geom_histogram(bins = 90) + 
  xlim(0, 6000) + 
  facet_wrap(~subject)
## Warning: Removed 84 rows containing missing values (geom_bar).

complexity difference

d %>% 
  ggplot(aes(x = trial_looking_time, 
            fill = trial_stimulus_complexity), 
         ) + 
  geom_density(alpha = 0.5)+ 
  xlim(0, 6000)

d %>% 
  ggplot(aes(x = trial_looking_time, 
            fill = trial_stimulus_complexity), 
         ) + 
  geom_density(alpha = 0.5)+ 
  xlim(0, 6000) + 
  facet_wrap(~subject)

block difference

d %>% 
  ggplot(aes(x = trial_looking_time, 
            fill = block), 
         ) + 
  geom_density(alpha = 0.5)+ 
  xlim(0, 6000)

d %>% 
  ggplot(aes(x = trial_looking_time, 
            fill = block), 
         ) + 
  geom_density(alpha = 0.5)+ 
  xlim(0, 6000) + 
  facet_wrap(~subject)

Complexity differences no target

d_no_target %>% 
  ggplot(aes(x = trial_looking_time, 
            fill = trial_stimulus_complexity), 
         ) + 
  geom_density(alpha = 0.5)+ 
  xlim(0, 6000)

d_no_target %>% 
  ggplot(aes(x = trial_looking_time, 
            fill = trial_stimulus_complexity), 
         ) + 
  geom_density(alpha = 0.5)+ 
  xlim(0, 6000) + 
  facet_wrap(~subject)

Block differences no target

d_no_target %>% 
  ggplot(aes(x = trial_looking_time, 
            fill = block), 
         ) + 
  geom_density(alpha = 0.5)+ 
  xlim(0, 6000)

d_no_target %>% 
  ggplot(aes(x = trial_looking_time, 
            fill = block), 
         ) + 
  geom_density(alpha = 0.5)+ 
  xlim(0, 6000) + 
  facet_wrap(~subject)
## Warning: Groups with fewer than two data points have been dropped.
## Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning -
## Inf

Visualizing aggregarded looking time

d_sum_individual <- d %>% 
  group_by(subject, block) %>% 
  summarise(
    mean_lt = mean(trial_looking_time, na.rm = TRUE), 
    sd = sd(trial_looking_time, na.rm = TRUE), 
    n = n(), 
    ci_range_95 = qt(1 - (0.05 / 2), n - 1) * (sd/sqrt(n)), 
    ci_ub = mean_lt + ci_range_95, 
    ci_lb = mean_lt - ci_range_95
  )
## `summarise()` regrouping output by 'subject' (override with `.groups` argument)
d_sum <- d %>% 
  group_by(block) %>% 
  summarise(
    mean_lt = mean(trial_looking_time, na.rm = TRUE), 
    sd = sd(trial_looking_time, na.rm = TRUE), 
    n = n(), 
    ci_range_95 = qt(1 - (0.05 / 2), n - 1) * (sd/sqrt(n)), 
    ci_ub = mean_lt + ci_range_95, 
    ci_lb = mean_lt - ci_range_95
  )
## `summarise()` ungrouping output (override with `.groups` argument)

aggregated

d_sum %>% ggplot(aes(x = block, y = mean_lt)) + 
  geom_pointrange(aes(ymin = ci_lb, ymax = ci_ub)) + 
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))

individual

something weird happened

d_sum_individual %>% 
  ggplot(aes(x = block, y = mean_lt)) + 
  geom_pointrange(aes(ymin = ci_lb, ymax = ci_ub)) +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))

d_sum_individual %>% 
  ggplot(aes(x = block, y = mean_lt)) + 
  geom_pointrange(aes(ymin = ci_lb, ymax = ci_ub))  + 
  facet_wrap(~subject) + 
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))

weird ones

We can see three very weird ones: SS1604513317537 SS1604515995769 SS1604516882157

weird <- c("SS1604513317537", 
           "SS1604515995769", 
           "SS1604516660396")

d_sum_individual %>% 
  filter(subject %in% weird) %>% 
  ggplot(aes(x = block, y = mean_lt)) + 
  geom_pointrange(aes(ymin = ci_lb, ymax = ci_ub))  + 
  facet_wrap(~subject) + 
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))

d %>% 
  filter(subject %in% weird) %>% 
  ggplot(aes(x = trial_looking_time)) + 
  geom_histogram(bins = 90) +
  facet_wrap(~subject) + 
  xlim(0, 6000)+
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))
## Warning: Removed 6 rows containing missing values (geom_bar).

Excluding weird ones

d_no_weird <- d %>% 
  filter(!(subject %in% weird)) 

  
d_no_weird_sum <- d_no_weird %>% 
  group_by(block) %>% 
  summarise(
    mean_lt = mean(trial_looking_time, na.rm = TRUE), 
    sd = sd(trial_looking_time, na.rm = TRUE), 
    n = n(), 
    ci_range_95 = qt(1 - (0.05 / 2), n - 1) * (sd/sqrt(n)), 
    ci_ub = mean_lt + ci_range_95, 
    ci_lb = mean_lt - ci_range_95
  )
## `summarise()` ungrouping output (override with `.groups` argument)
d_no_weird_sum %>% ggplot(aes(x = block, y = mean_lt)) + 
  geom_pointrange(aes(ymin = ci_lb, ymax = ci_ub)) + 
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))

# Basic model

basic_m <- lmer(log(trial_looking_time) ~ trial_stimulus_type * block + (1|subject), 
     data = d)
summary(basic_m)
## Linear mixed model fit by REML ['lmerMod']
## Formula: log(trial_looking_time) ~ trial_stimulus_type * block + (1 |  
##     subject)
##    Data: d
## 
## REML criterion at convergence: 10616.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.3471 -0.5241 -0.1523  0.3587  5.4042 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  subject  (Intercept) 0.1001   0.3164  
##  Residual             0.2227   0.4719  
## Number of obs: 7769, groups:  subject, 42
## 
## Fixed effects:
##                                                       Estimate Std. Error
## (Intercept)                                           6.218527   0.050443
## trial_stimulus_typedeviant                            0.219409   0.030670
## trial_stimulus_typetarget                             0.613224   0.031048
## blockall_simple                                       0.006138   0.017736
## blockmixed_complex_deviant                            0.027101   0.017838
## blockmixed_simple_deviant                             0.013656   0.018082
## trial_stimulus_typedeviant:blockall_simple            0.012400   0.043358
## trial_stimulus_typetarget:blockall_simple             0.042841   0.043881
## trial_stimulus_typedeviant:blockmixed_complex_deviant 0.015950   0.043425
## trial_stimulus_typetarget:blockmixed_complex_deviant  0.110322   0.044058
## trial_stimulus_typedeviant:blockmixed_simple_deviant  0.040369   0.044142
## trial_stimulus_typetarget:blockmixed_simple_deviant   0.166104   0.044662
##                                                       t value
## (Intercept)                                           123.277
## trial_stimulus_typedeviant                              7.154
## trial_stimulus_typetarget                              19.751
## blockall_simple                                         0.346
## blockmixed_complex_deviant                              1.519
## blockmixed_simple_deviant                               0.755
## trial_stimulus_typedeviant:blockall_simple              0.286
## trial_stimulus_typetarget:blockall_simple               0.976
## trial_stimulus_typedeviant:blockmixed_complex_deviant   0.367
## trial_stimulus_typetarget:blockmixed_complex_deviant    2.504
## trial_stimulus_typedeviant:blockmixed_simple_deviant    0.915
## trial_stimulus_typetarget:blockmixed_simple_deviant     3.719
## 
## Correlation of Fixed Effects:
##                              (Intr) trl_stmls_typd trl_stmls_typt blckl_
## trl_stmls_typd               -0.101                                     
## trl_stmls_typt               -0.100  0.164                              
## blckll_smpl                  -0.175  0.288          0.284               
## blckmxd_cm_                  -0.177  0.286          0.283          0.495
## blckmxd_sm_                  -0.172  0.282          0.279          0.489
## trl_stmls_typd:_              0.072 -0.707         -0.116         -0.409
## trl_stmls_typt:_              0.071 -0.116         -0.707         -0.404
## trl_stmls_typdvnt:blckmxd_c_  0.071 -0.706         -0.116         -0.203
## trl_stmls_typtrgt:blckmxd_c_  0.071 -0.116         -0.705         -0.200
## trl_stmls_typdvnt:blckmxd_s_  0.070 -0.695         -0.114         -0.200
## trl_stmls_typtrgt:blckmxd_s_  0.070 -0.114         -0.695         -0.198
##                              blckmxd_c_ blckmxd_s_ trl_stmls_typd:_
## trl_stmls_typd                                                     
## trl_stmls_typt                                                     
## blckll_smpl                                                        
## blckmxd_cm_                                                        
## blckmxd_sm_                   0.490                                
## trl_stmls_typd:_             -0.203     -0.200                     
## trl_stmls_typt:_             -0.200     -0.197      0.165          
## trl_stmls_typdvnt:blckmxd_c_ -0.406     -0.200      0.500          
## trl_stmls_typtrgt:blckmxd_c_ -0.402     -0.197      0.082          
## trl_stmls_typdvnt:blckmxd_s_ -0.199     -0.406      0.491          
## trl_stmls_typtrgt:blckmxd_s_ -0.197     -0.401      0.081          
##                              trl_stmls_typt:_ trl_stmls_typdvnt:blckmxd_c_
## trl_stmls_typd                                                            
## trl_stmls_typt                                                            
## blckll_smpl                                                               
## blckmxd_cm_                                                               
## blckmxd_sm_                                                               
## trl_stmls_typd:_                                                          
## trl_stmls_typt:_                                                          
## trl_stmls_typdvnt:blckmxd_c_  0.082                                       
## trl_stmls_typtrgt:blckmxd_c_  0.499            0.164                      
## trl_stmls_typdvnt:blckmxd_s_  0.081            0.491                      
## trl_stmls_typtrgt:blckmxd_s_  0.492            0.081                      
##                              trl_stmls_typtrgt:blckmxd_c_
## trl_stmls_typd                                           
## trl_stmls_typt                                           
## blckll_smpl                                              
## blckmxd_cm_                                              
## blckmxd_sm_                                              
## trl_stmls_typd:_                                         
## trl_stmls_typt:_                                         
## trl_stmls_typdvnt:blckmxd_c_                             
## trl_stmls_typtrgt:blckmxd_c_                             
## trl_stmls_typdvnt:blckmxd_s_  0.080                      
## trl_stmls_typtrgt:blckmxd_s_  0.490                      
##                              trl_stmls_typdvnt:blckmxd_s_
## trl_stmls_typd                                           
## trl_stmls_typt                                           
## blckll_smpl                                              
## blckmxd_cm_                                              
## blckmxd_sm_                                              
## trl_stmls_typd:_                                         
## trl_stmls_typt:_                                         
## trl_stmls_typdvnt:blckmxd_c_                             
## trl_stmls_typtrgt:blckmxd_c_                             
## trl_stmls_typdvnt:blckmxd_s_                             
## trl_stmls_typtrgt:blckmxd_s_  0.164